import time
from selenium.webdriver.common.by import By


class LoginOperation():
    def login(self, driver, username, password):
        ele1 = driver.find_element(By.XPATH, "//*[@id='username']")
        ele1.send_keys(username)
        time.sleep(3)
        ele2 = driver.find_element(By.ID, 'password')
        ele2.send_keys(int(password))
        time.sleep(3)
        ele3 = driver.find_element(By.ID, 'login_btn')
        ele3.click()
        time.sleep(5)

    def getTitle(self, driver):
        return driver.title

    def getUsernameErrorResult(self, driver):
        return driver.find_element_by_xpath('/html/body/div/div/div/form/div[1]/span[1]').text

    def getPasswordErrorResult(self, driver):
        return driver.find_element_by_xpath('/html/body/div/div/div/form/div[2]/span[1]').text
